package cn.maidouya.hrm.controller;

import cn.maidouya.hrm.dto.SmsDto;
import cn.maidouya.hrm.service.IImageCodeControllerServer;
import cn.maidouya.hrm.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.io.IOException;

/**
 *   注册页面 刷新出来验证码
 *   key由前端生成保证key不出现重复sessionStorage
 */
@RestController
@RequestMapping("/verifycode")
public class ImageCodeController {
    @Autowired
    private IImageCodeControllerServer imageCodeControllerServer;

    /**
     *
     * @param imageCodeKey key
     * @return
     * @throws IOException
     */
    @GetMapping("/imageCode/{key}")
    public AjaxResult getImageCodeKey(@PathVariable("key") String imageCodeKey) throws IOException {
       return imageCodeControllerServer.getImageCodeKey(imageCodeKey);
    }
    @PostMapping("/sendSmsCode")
    public AjaxResult sendSmsCode(@RequestBody @Valid SmsDto smsDto) {
        return imageCodeControllerServer.sendSmsCode(smsDto);
    }
}
